package com.hu.hutool.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Author CazCen
 * @Date 2021/11/3 15:40
 */
@Getter
@AllArgsConstructor
public enum ErrorCodeEnum {

    USER_ID_ERROR(1000001, "自增id不能为空"),
    USER_PHONE_ERROR(1000002, "手机号码不能为空");

    private Integer code;

    private String msg;

    public static String getMsgByCode(Integer code) {

        if (ObjectUtil.isEmpty(code)) {
            return "";
        }

        for (ErrorCodeEnum value : ErrorCodeEnum.values()) {
            if (value.getCode().equals(code)) {
                return value.getMsg();
            }
        }
        return "";
    }

}
